package cn.leelei.spring.test;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.leelei.spring.dao.UserDao;

/**
 * 测试生命周期
 * 
 * @author Nike
 *
 */
public class UserDaoSpring {
	/**
	 * 获得getContext()抽取
	 * 
	 * @return
	 */
	private ApplicationContext getContext() {
		ApplicationContext context = new ClassPathXmlApplicationContext("beans4.xml");
		return context;
	}

	/**
	 * 
	 * 测试生命周期方法
	 * 1.通过名称进行获取
	 */
	@Test
	public void getUserDao() {

		UserDao userDao = getContext().getBean(UserDao.class);
		userDao.Save();

	}

}
